#include "../include/catlive2d.hpp"
#include "../include/Live2dDelegate.hpp"

bool cat_live2d_initailize()
{
    if (!Live2dDelegate::GetInstance()->IsInitialize())
        return Live2dDelegate::GetInstance()->Initialize();
    return true;
}

void cat_live2d_release()
{
    if (Live2dDelegate::GetInstance()->IsInitialize()){
        Live2dDelegate::GetInstance()->Release();
        Live2dDelegate::ReleaseInstance();
    }
}

bool cat_live2d_load_model(const char* dir, const char* fileName)
{
    if (Live2dDelegate::GetInstance()->IsInitialize())
        return Live2dDelegate::GetInstance()->LoadModelFromFile(dir, fileName);
    return false;
}

void cat_live2d_release_model()
{
    if (Live2dDelegate::GetInstance()->IsInitialize())
        Live2dDelegate::GetInstance()->ReleaseModel();
}

bool cat_live2d_resize(int width, int height)
{
    return Live2dDelegate::GetInstance()->Resize(width, height);
}

bool cat_live2d_scale(float s_x, float s_y)
{
    return Live2dDelegate::GetInstance()->Scale(s_x,s_y);
}

bool cat_live2d_translate(float t_x, float t_y)
{
    return Live2dDelegate::GetInstance()->Translate(t_x, t_y);
}

void cat_live2d_speed(float sp)
{
    Live2dDelegate::GetInstance()->SetSpeed(sp);
}

void cat_live2d_run(void* texture)
{
    Live2dDelegate::GetInstance()->Run(texture);
}

void cat_live2d_on_mouse_move_callback(float m_x, float m_y)
{
    Live2dDelegate::GetInstance()->OnMouseMoveCallBack(m_x,m_y);
}

void cat_live2d_on_mouse_click_callback(const cat_mouse_click_event* event, bool mouse_up)
{
    Live2dDelegate::GetInstance()->OnMouseClickCallBack(event,mouse_up);
}

void cat_live2d_on_left_hand_down_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnLeftHandDownCallBack(key_up);
}

void cat_live2d_on_right_hand_down_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnRightHandDownCallBack(key_up);
}

void cat_live2d_joy_on_left_stick_down_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnStickLeftDownCallBack(key_up);
}

void cat_live2d_joy_on_right_stick_down_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnStickRightDownCallBack(key_up);
}

void cat_live2d_joy_on_show_left_hand_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnStickShowLeftHandCallBack(key_up);
}

void cat_live2d_joy_on_show_right_hand_callback(bool key_up)
{
    Live2dDelegate::GetInstance()->OnStickShowRightHandCallBack(key_up);
}

void cat_live2d_joy_on_l_stick_move_callback(float m_x, float m_y)
{
    Live2dDelegate::GetInstance()->OnStickLCallBack(m_x, m_y);
}

void cat_live2d_joy_on_r_stick_move_callback(float m_x, float m_y)
{
    Live2dDelegate::GetInstance()->OnStickRCallBack(m_x, m_y);
}

void cat_live2d_play_motion(const char* motionGroup, int motionId)
{
    Live2dDelegate::GetInstance()->StartMotion(motionGroup, motionId);
}

void cat_live2d_set_expression(const char* ExpressionId)
{
    Live2dDelegate::GetInstance()->StartExpression(ExpressionId);
}

void cat_live2d_set_expression_by_id(const int ExpressionId)
{
    Live2dDelegate::GetInstance()->StartExpressionById(ExpressionId);
}

void cat_live2d_set_random_motion(const bool random, const bool randomExpression)
{
    Live2dDelegate::GetInstance()->SetRandomMotion(random, randomExpression);
}


